{% extends "admin/change_form.html" %}
{% load i18n admin_urls %}
{% load filters %}

{% block field_sets %}
{% for fieldset in adminform %}
    <fieldset class="module aligned {{ fieldset.classes }}">
        {% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
        {% if fieldset.description %}
            <div class="description">{{ fieldset.description|safe }}</div>
        {% endif %}
        {% for line in fieldset %}
            <div class="form-row{% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
                {% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %}
                {% for field in line %}
                    {% if field.field.name in includes %}
                        {{ field.label_tag }}
                        <div class="form-row field-name">
                            {% if field.field.value %}
                                <input value="{{ field.field.value }}" type="hidden" name="{{ field.field.name }}"/>
                            {% endif %}
                            {% include includes|key:field.field.name|key:'template' with form=includes|key:field.field.name|key:'form' %}
                        </div>
                    {% else %}
                        <div{% if not line.fields|length_is:'1' %} class="field-box{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}>
                            {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
                            {% if field.is_checkbox %}
                                {{ field.field }}{{ field.label_tag }}
                            {% else %}
                                {{ field.label_tag }}
                                {% if field.is_readonly %}
                                    <p>{{ field.contents|linebreaksbr }}</p>
                                {% else %}
                                    {{ field.field }}
                                {% endif %}
                            {% endif %}
                            {% if field.field.help_text %}
                                <p class="help">{{ field.field.help_text|safe }}</p>
                            {% endif %}
                        </div>
                    {% endif %}
                {% endfor %}
            </div>
        {% endfor %}
    </fieldset>
{% endfor %}
{% endblock %}